#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

long long ch[10000];
int arr[10000][2];

int main()
{
	int n, j;
	scanf("%d %d", &n, &j);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &ch[i]);
	}
	int k = 0;
	for (k = 0; k < j; k++)
	{
		int sum = 0;
		for (int g = 0; g < 2; g++)
			scanf("%d", &arr[k][g]);
		for (int w = arr[k][0]-1; w < arr[k][1]; w++)
		{
			sum += ch[w];
		}
		printf("%lld\n", sum);

	}

	return 0;
}